﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserInfo.aspx.cs" Inherits="RN.ERP.Web.AccountHelp.UserInfo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link rel="Stylesheet" type="text/css" href="../Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <link rel="Stylesheet" type="text/css" href="../Styles/skins/blue/css/style.css" />
    <link rel="Stylesheet" type="text/css" href="../Styles/skins/blue/css/style_msg.css" />

    <style>
        .IE6png
        {
            behavior: url("js/iepngfix.htc");
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="main_tt">
        <div class="main_tt_r_p15">
            <!--title_tt 开始-->
            <div class="title_tt">
                <div class="title_tt_l">
                    <img src="../images/tt_title_l.jpg" width="9" height="33" /><img src="../images/xx_icon.jpg"
                        width="24" height="33" /></div>
                <div class="title_tt_h">
                    用户信息</div>
                <div class="title_tt_r">
                    <img src="../images/tt_title_r.jpg" width="9" height="33" /></div>
            </div>
            <!--title_tt 结束-->
            <!--userinfo_tt 开始-->
            <div class="userinfo_tt">
                <div class="xian">
                    <div class="about_title">
                        用户基本信息</div>
                </div>
                <div>
                    <form>
                    <div class="userinfo_tt_left">
                        <ul>
                            <li>
                                <label>登录用户名</label>
                                <span class="input_l"><img src="../images/input_l.jpg" width="10" height="31" alt="" /></span>
                                <span class="input_mm">
                                    <input id="txtLoginName" runat="server" type="text" readonly class="inp" />
                                </span>
                                <span class="input_r"><img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                            </li>
                            <li>
                                <label>
                                    用户名称</label>
                                <span class="input_l">
                                    <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                        <input id="txtUserName" runat="server" type="text"  readonly class="inp" /></span> <span class="input_r">
                                            <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                            </li>
                        </ul>
                    </div>

                    <!--专家系统暂时隐藏头像上传，以后有可能会补上-->
                    <div class="userinfo_tt_right" style="display:<%=SystemID=="95"?"none":"block"%>">
                        <div class="photo_tt">
                            <img src="" width="170" height="140" />
                        </div>
                        <div>
                            <input name="" type="file" class="liulan_tt" />
                        </div>
                        <div class="ckicon">
                            <a href="#">修改头像</a></div>
                    </div>
                    </form>
                </div>
                <div class="clear">
                </div>
                <div class="xian">
                    <div class="about_title">
                        修改密码</div>
                </div>
                <form>
                <div class="userinfo_tt_left">
                    <ul>
                        <li>
                            <label>
                                新密码</label>
                            <span class="input_l">
                                <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                    <input id="txtNewPwd" type="password" class="inp" /></span> <span class="input_r">
                                        <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                        </li>
                        <li>
                            <label>
                                确认密码</label>
                            <span class="input_l">
                                <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                    <input id="txtPwdConfirm" type="password" class="inp" /></span> <span class="input_r">
                                        <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                        </li>
                        <li>
                            <label>&nbsp;</label>
                            <span class="ckicon02"><a href="javascript:changePwd()">修改密码</a></span>
                        </li>
                    </ul>
                </div>
                <div class="clear">
                </div>
                </form>

                <div style="display:<%=SystemID=="101"?"block":"none"%>">
                <div id="orginazation_title" class="xian">
                    <div class="about_title">
                        修改组织机构代码</div>
                    <div style=" float:left; margin: 10px auto auto 5px; color:Red;">
                        组织机构代码审核状态：<label id="lbOrgFlowCodeStr"></label>
                    </div>
                </div>
                <form>
                <div id="orginazation_reset" class="userinfo_tt_left" style="width:50%">
                    <ul>
                        <li>
                            <label style="width:30%">
                                新组织机构代码</label>
                            <span class="input_l">
                                <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                    <input id="txtNewOrginazationCode" type="text" class="inp" /></span> <span class="input_r">
                                        <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                        </li>
                        <li>
                            <label style="width:30%">
                                确认组织机构代码</label>
                            <span class="input_l">
                                <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                    <input id="txtOrginazationCodeConfirm" type="text" class="inp" /></span> <span class="input_r">
                                        <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                        </li>
                        
                        <li>
                            <label>&nbsp;</label>
                            <div id="alterOrgCodeDiv">
                            <span class="ckicon02"><a href="javascript:resetOrginazationCode()">修改机构代码</a></span>
                            </div>
                        </li>
                    </ul>
                </div>
                <div style="width:45%; padding-top:5px; float:right">
                    <div>
                        <img src='' id="imgCorpOrg" alt="" style="display: none; width: 220px; height: 150px;"
                            class="pointer" FuncCode="CorpORGChange" syscode="EF" checkempty="yes" />
                    </div>
                    <label >
                        上传组织机构代码扫描件&nbsp;&nbsp;</label>
                    <div id="corpOrgUploadDiv">
                        <a href="javascript:void(0);" id="corpOrgUpload">
                        <img alt="上传" src="../images/btn.jpg" /></a>
                    </div>
                </div>
                <div class="clear">
                </div>
                </form>
                </div>
                
            </div>
            <!--userinfo_tt 结束-->
        </div>
    </div>
    </form>
</body>
<script type="text/javascript" src="../Scripts/jquery.min.js"></script>
<script type="text/javascript" src="../Scripts/ligerUI/js/ligerui.all.js"></script>
<script src="../Scripts/json-data.js" type="text/javascript"></script>
<script type="text/javascript">
    
    var corpUserGuid = "<%=CorpUserGuid %>";
    GetUserInfo();
    
    function GetUserInfo() {
        $.ligerDialog.waitting("信息加载中...");

        $.ajax({
            type: 'post',
            dataType: 'json',
            url: '../Handlers/UserInfoHandler.ashx',
            data: { action: "GetUserInfo" },
            success: function (rst) {
                ShowUserInfo(rst);
            },
            error: function () {
                $.ligerDialog.error('信息加载失败。');
            },
            complete: function () {
                $.ligerDialog.closeWaitting();
            }
        });
    }

    function ShowUserInfo(user) {
        $("#txtLoginName").val(user.UserName);
        $("#txtUserName").val(user.Name);
        if (user.RoleType == "user") {
            $("#txtUserType").val(user.UserType);
            $("#txtTel").val(user.Tel);
            $("#txtMail").val(user.Mail);
        } else {
            $("#txtUserType,#txtTel,#txtMail").hide();
            $("#orginazation_title,#orginazation_reset").hide();
        }
        
    }

    function changePwd() {
        
        if(SubmitCheck()){
            $.ligerDialog.waitting("正在处理中,请稍后...");

            $.ajax({
                type: 'post',
                dataType: 'text',
                url: '../Handlers/UserInfoHandler.ashx',
                data: { action: "ChangePwd", newPwd: $("#txtPwdConfirm").val() },
                success: function (result) {
                    if (result == "success") {
                        $.ligerDialog.alert('密码修改成功！');
                        $("#txtNewPwd").val("");
                        $("#txtPwdConfirm").val("");
                    } else {
                        $.ligerDialog.error('处理失败，请再次尝试。');
                    }
                },
                error: function () {
                    $.ligerDialog.error('处理失败，请再次尝试。');
                },
                complete: function () {
                    $.ligerDialog.closeWaitting();
                }
            });
        }

    }

    ////修改组织机构代码
    function resetOrginazationCode() {

        if (OrginazationCheck()) {
            $.ligerDialog.waitting("正在处理中,请稍后...");

            $.ajax({
                type: 'post',
                dataType: 'text',
                url: '../Handlers/UserInfoHandler.ashx',
                data: { action: "resetOrginazationCode", newGroupCode: $("#txtOrginazationCodeConfirm").val(), "funcCode": "CorpORGChange" },
                success: function (result) {
                    if (result == "success") {
                        $.ligerDialog.alert('提交修改组织机构代码成功，待主管审核后自动变更。');
                        DisableBtn();
                        $("#lbOrgFlowCodeStr").empty();
                        $("#lbOrgFlowCodeStr").append("上报");
                    } else {
                        var msg = result == "" ? '处理失败，请再次尝试。' : result;
                        $.ligerDialog.error(msg);
                    }
                },
                error: function () {
                    $.ligerDialog.error('处理失败，请再次尝试。');
                },
                complete: function () {
                    $.ligerDialog.closeWaitting();
                }
            });
        }

    }
    function SubmitCheck() {
        var newPwd = $("#txtNewPwd").val();
        var confirmPwd = $("#txtPwdConfirm").val();
        var error = "";

        if (!newPwd) {
            error = "请输入密码。";
        }else if (!/^[.]{6,}$/.test(newPwd)) {
            error = "密码不能少于6位。";
        }else if (newPwd != confirmPwd) {
            error = "两次输入的密码不一致。";
        }
        if (error) {
            $.ligerDialog.error(error);
            return false;
        }
        return true;
    }

    function OrginazationCheck() {
        var newOrginazation = $("#txtNewOrginazationCode").val();
        var confirmOrginazation = $("#txtOrginazationCodeConfirm").val();
        var error = "";

        if (!newOrginazation) {
            error = "请输入组织机构代码。";
        } else if (!/\d{8}[-][\d|X]/.test(newOrginazation)) {
            error = "请输入正确格式的组织机构代码。";
        } else if (newOrginazation != confirmOrginazation) {
            error = "两次输入的组织机构代码不一致。";
        }
        if (error) {
            $.ligerDialog.error(error);
            return false;
        }
        return true;
    }

    //加载组织机构代码数据并赋值
    GetOrgData();
    function GetOrgData() {
        var datas = {};
        datas.action = "getorgdata";
        datas.rand = Math.random();
        $.getJSON("../Handlers/UserInfoHandler.ashx", datas, function (data) {
            if (data && data.OrgCode) {//页面控件赋值
                $("#txtNewOrginazationCode").val(data.OrgCode);
                $("#txtOrginazationCodeConfirm").val(data.OrgCode);
                
                
                var innerHTML = data.FlowCodeStr;
                $("#lbOrgFlowCodeStr").empty();
                $("#lbOrgFlowCodeStr").append(innerHTML);
                ImgShow();
                if (data.FlowCodeStr == "上报") {
                    DisableBtn();
                }
            }
            else if (data && data.FlowCodeStr) {
                var innerHTML = data.FlowCodeStr;
                $("#lbOrgFlowCodeStr").empty();
                $("#lbOrgFlowCodeStr").append(innerHTML);
            }
            else {
                $("#lbOrgFlowCodeStr").empty();
                $("#lbOrgFlowCodeStr").append("未上报");
            }
        });
    }
    
    //上传组织机构代码扫描件
    $("#corpOrgUpload").click(function () {
        if ($("#txtNewOrginazationCode").val() == "") {
            OpenAlert("请先填写组织机构代码！");
            return false;
        }
        if ($("#txtOrginazationCodeConfirm").val() == "") {
            OpenAlert("请先填写确认组织机构代码！");
            return false;
        }

        var title = "上传组织机构代码扫描件";
        $.ligerDialog.open({ url: "../UserControl/FileUploadList.aspx?title=" + escape(title) + "&filename=" + corpUserGuid + " &FuncCode=CorpORGChange", width: 650, height: 570, title: '' });
        return false;
    });

    //加载扫描件
    function ImgShow() {
        $("#imgCorpOrg").attr("src", "../Handlers/GetFileHandler.ashx?fileName=" + corpUserGuid + ".jpg&sysCode=EF&funcCode=CorpORGChange&rand=" + Math.random());
        $("#imgCorpOrg").show();
    }
    /*关闭窗口*/
    function OnClientCloseImg(args) {
        var arg = args;
        if (arg) {
            if (arg.Result == 1) {
                return;
            }
            ImgShow();
        }
    }
    function returnToParent() {
        window.parent.$.ligerDialog.close(); ////关闭dialog
        parent.$(".l-dialog,.l-window-mask").hide(); ////去除父窗体遮罩层
    }

    /*打开添加扫描件窗口*/
    function ShowUpForm(u, w, h, win) {
        win = win || this;
        $.ligerDialog.open({ url: u, width: w, height: h, title: '', buttons: [{ text: '关闭', onclick: function (item, dialog) { dialog.close(); } }] });
        win.ChildDialogWin = this;
        return false;
    }
    /*上传组织机构代码扫描件*/
    $("#imgCorpOrg").click(function () {
        var title = "查看组织机构代码扫描件";
        $.ligerDialog.open({ url: "../Enterprise/UploadFileShowList.aspx?title=" + escape(title) + "&fileName=" + corpUserGuid + "&fileType=.jpg&sysCode=EF&funcCode=CorpORGChange",
            width: 760, height: 650, title: '', isResize: true,
            buttons: [{ text: '关闭', onclick: function (item, dialog) { dialog.close(); } }]
        });
        return false;
    });

    function DisableBtn() {
        $("#txtNewOrginazationCode").attr("disabled", "disabled");
        $("#txtOrginazationCodeConfirm").attr("disabled", "disabled");
        $("#corpOrgUploadDiv").css("display", "none");
        $("#alterOrgCodeDiv").css("display", "none");
    }


    
</script>
</html>
